-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finance #124
Conversation
"on_failure_callback": lambda x: "Need to send notification to Discord", | ||
} | ||
dag = DAG( | ||
"DISCORD_CHORES_REMINDER", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need to rename this~
write_to_bigquery(df_diff) | ||
# push to discord | ||
webhook_url = os.getenv("discord_data_stratagy_webhook") | ||
username = "財務機器人" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
# read xls from google doc to df. | ||
df_xls = read_google_xls_to_df() | ||
# read bigquery to df. | ||
df_bigquery = read_bigquery_to_df() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for writing comments~
|
||
def write_to_bigquery(df) -> None: | ||
project_id = "pycontw-225217" | ||
dataset_id = "test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember to update the dataset id~
dags/app/finance_bot/udf.py
Outdated
msg = refine_diff_df_to_string(df_diff) | ||
discord.send_webhook_message(webhook_url, username, msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just my two cents, but maybe we don't need to send any msg if there's no updates. Otherwise, that channel might be very noisy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modify if msg is no data it didn't send msg
def df_difference(df_xls, df_bigquery) -> pd.DataFrame: | ||
merged = pd.merge(df_xls, df_bigquery, how="outer", indicator=True) | ||
return merged[merged["_merge"] == "left_only"].drop("_merge", axis=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
else: | ||
for row in df.itertuples(index=False): | ||
msg += f"{row[0]}, 花費: {row[1]}, {row[3]}, {row[4]}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯. What do you think about calculating the total expenses as well as the expenses per group in your next PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFG!
Types of changes
Description
add finance bot
Checklist:
poetry run pytest
locally to ensure all linter checks pass